﻿<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  
    <xsl:output method="xml" indent="yes" omit-xml-declaration="no" />

    <xsl:template match="/">
      <NSFFundingMillions
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="NSFFundingSchema.xsd">
        <xsl:for-each select="NSFFundingMillions/*">
          <fiscalYear>
            <year>
              <xsl:variable name ="year" select="substring(name(),3,4)"/>
              <xsl:copy-of select="$year" />,0,1</year>
              <fund>
                <beneficiary>Research and Related Activities</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/RRA/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/RRA/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
              <fund>
                <beneficiary>Education and Human Resources</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/EHR/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/EHR/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
              <fund>
                <beneficiary>Academic Research Infrastructure</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/ARI/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/ARI/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
              <fund>
                <beneficiary>Major Research Equipment and Facilities Construction</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/MREFC/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/MREFC/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
              <fund>
                <beneficiary>Agency Operations and Award Management</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/AOAM/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/AOAM/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
              <fund>
                <beneficiary>Office of Inspector General</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/OIG/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/OIG/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
              <fund>
                <beneficiary>National Science Board</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/NSB/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/NSB/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
              <fund>
                <beneficiary>National Science Foundation Total</beneficiary>
                <currentValue>
                  <xsl:value-of select="translate(translate(translate(CurrentDollars/NSFTotal/.,'$',''),',',''),' ','')"/>
                </currentValue>
                <constantValue>
                  <xsl:value-of select="translate(translate(translate(ConstantDollars/NSFTotal/.,'$',''),',',''),' ','')"/>
                </constantValue>
              </fund>
            </fiscalYear>
          </xsl:for-each>
        </NSFFundingMillions>
    </xsl:template>
</xsl:stylesheet>
